﻿#region Using directives

using System;
using System.Collections.Generic;
using System.Text;

#endregion

namespace MetaHeuristics.Aco
{
    /// <summary>
    /// A <em>Ellitist Ant</em> damoen action.
    /// </summary>
    public class EllitistAntDaemonAction : BaseDaemonAction
    {
        private float weight = 5;

        /// <summary>
        /// Gets or sets the additional weight given to the <em>best-so-far</em> ant.
        /// </summary>
        public float Weight
        {
            get
            {
                return this.weight;
            }
            set
            {
                this.weight = value;
            }
        }

        /// <summary>
        /// Deposits additional pheromone on the track of the best ant.
        /// </summary>
        public override void Act()
        {
            float deltaTau = this.weight / this.Aco.BestAnt.Tours.Length;

            for (int i = 0; i < this.Aco.Cities.Count; ++i)
            {
                int j = this.Aco.BestAnt.Tours[i];
                int l = this.Aco.BestAnt.Tours[i + 1];

                this.Aco.Pheromones[j, l] += deltaTau;
            }
        }
    }
}
